<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <title>Hiring-企业后台</title>
         <%@ include file="/WEB-INF/views/common/import.jsp"%>
    </head>
    <body>
   
    	<div class="container">
    		<strong class="welcome-title">欢迎您，${company.name }</strong>
    		<a href="<%=request.getContextPath()%>/CompanyServlet?command=logout">
    		<button type="button" class="btn btn-warning pull-right">注　　销</button>
    		</a>
    		<span class="pull-right">&nbsp;</span>
    		<a href="<%=request.getContextPath()%>/CompanyServlet?command=toUpdatePasswordUI">
    		<button type="button" class="btn btn-warning pull-right">修改密码</button>
    		</a>
    		<span class="pull-right">&nbsp;</span>
    		<a href="<%=request.getContextPath()%>/CompanyServlet?command=toQueryCompanyUI&id=${company.id}">
    		<button type="button" class="btn btn-warning pull-right">基本信息</button>
    		</a>
    		<span class="pull-right">&nbsp;</span>
    		<a href="<%=request.getContextPath()%>/CommonServlet?command=toMainUI">
    		<button type="button" class="btn btn-warning pull-right">返回首页</button>
    		</a>
	    	<hr/>
	    	<ol class="breadcrumb">
			  <li class="active">主页</li>
			</ol>
	    	<span class="resume">职位管理</span>
	    	<a href="<%=request.getContextPath()%>/PositionServlet?command=toAddUI">发布职位</a>
	    	<table class="table">
		      <thead>
		        <tr>
		         <th>编号</th>
				 <th>职位名称</th>
				 <th>薪资范围</th>
				 <th>发布时间</th>
				 <th>操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      <c:if test="${empty positionList}">
		      		<tr><td colspan="5" align="center">没有相关数据！</td></tr>
		      	</c:if>
		      	<c:if test="${! empty positionList}">
		      <c:forEach items="${positionList }" var="position" varStatus="v">
			<tr>
				<th scope="row">${v.count }</th>
				<td><a
					href="<%=request.getContextPath()%>/PositionServlet?command=preupdate&id=${position.id}" onclick="return confirm('是否修改？');">${position.name }</a></td>
				<td>${position.salary1 }-${position.salary2 }</td>
				<td><fmt:formatDate value="${position.releaseTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
				<td><a
					href="javascript:void(0)"
					onclick="del(this,${position.id});">删除</a></td>
			</tr>
			</c:forEach>
			</c:if>
			      </tbody>
		    </table>
		    <table class="table">
	<caption>
		<strong>二、审核管理：</strong>
	</caption>
	<thead>
		<tr>
			<td colspan="7">
				<form id="searchForm" action="<%=request.getContextPath() %>/ApplicationServlet?command=listCompanyVerifyByPage" method="post">
					职位名称：<input type="text" name="positionName" value="${applicationCondition.position$name }">
					审核状态：<select name="status">
								<option value="0" <c:if test="${applicationCondition.status == 0}">selected=selected</c:if>>-全部-</option>
								<option value="1" <c:if test="${applicationCondition.status == 1}">selected=selected</c:if>>待审核</option>
								<option value="2" <c:if test="${applicationCondition.status == 2}">selected=selected</c:if>>已通过</option>
								<option value="3" <c:if test="${applicationCondition.status == 3}">selected=selected</c:if>>已拒绝</option>
							</select>
							申请时间(起止)：
	    			<input type="text" name="appTimeStart" value="${application.appTimeStart}" id="d4311" class="Wdate" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'d4312\')||\'2020-10-01\'}',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
		    		-
		    		<input type="text" name="appTimeEnd" value="${application.appTimeEnd}"  id="d4312" class="Wdate" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}',maxDate:'2020-10-01',dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
	    			<button>查询</button>
				</form>
			</td>
		</tr>
		<tr>
			<th>编号</th>
			<th>职位名称</th>
			<th>求职者</th>
			<th>简历信息</th>
			<th>申请时间</th>
			<th>审核状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach items="${pageModel.list }" var="application" varStatus="v">
			<tr>
				<th scope="row">${v.count }</th>
				<td>${application.position$name }</td>
				<td><a href="javascript:void(0)">${application.talent$name }</a></td>
				<td><a href="javascript:void(0)">${application.resume$intention }</a></td>
				<td><fmt:formatDate value="${application.appTime }"
						pattern="yyyy-MM-dd HH:mm:ss" /></td>
				<td>
					<c:if test="${application.status == 1 }">
						${application.statusStr }
					</c:if>
					<c:if test="${application.status != 1 }">
						${application.statusStr }
						(<fmt:formatDate value="${application.handleTime }" pattern="yyyy-MM-dd HH:mm:ss" />)
					</c:if>				
				</td>
				<td><a
					href="javascript:void(0);" onclick="verify(this,${application.id })">审核</a></td>
			</tr>
		</c:forEach>
		<tr>
			<td colspan="7" align="right">
				 <div class="pull-right">
		        	<button type="button" class="btn btn-default" onclick="go(${pageModel.first })" <c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>首页</button>
		        	<button type="button" class="btn btn-default" onclick="go(${pageModel.pre })" <c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>上一页</button>
		        	<select onchange="go(this.value)" class="select">
		        		<script>
		        			var totalPage = '${pageModel.totalPage }';
		        			var pageNo = '${pageModel.pageNo}'
		        			for (var i = 1; i <= totalPage; i++) {
		        				if (i == pageNo) {
		        				   document.write('<option value="'+ i +'" selected>第' + i +'页</option>');
		        				} else {
		        				   document.write('<option value="'+ i +'">第' + i +'页</option>');	
		        				}
		        			}
		        		</script>
		        	</select>
		        	<button type="button" class="btn btn-default" onclick="go(${pageModel.next })" <c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>下一页</button>
		        	<button type="button" class="btn btn-default" onclick="go(${pageModel.last })" <c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>尾页</button>
		        	&nbsp;&nbsp;&nbsp;&nbsp;
		        	<c:if test="${((pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize)< pageModel.totalRecords}">
		        	当前第${pageModel.pageNo }页，
		        	显示${(pageModel.pageNo - 1) * pageModel.pageSize + 1}到第${(pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize}，共${pageModel.totalPage }页
		        	</c:if>
		        	
		        	<c:if test="${((pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize)> pageModel.totalRecords}">
		        	当前第${pageModel.pageNo }页，
		        	显示${(pageModel.pageNo - 1) * pageModel.pageSize + 1}到第${pageModel.totalRecords}，共${pageModel.totalPage }页
		        	</c:if>
		        </div>
			</td>
		</tr>
	</tbody>
</table>
		    
		    
    	</div>
    	<script src="<%=request.getContextPath()%>/static/common/vendor/My97DatePicker/WdatePicker.js"></script>
<script >
    	/**
    	 * 信息提示框
    	 */
    	toastr.options = {
    			"closeButton": false,
    			  "debug": false,
    			  "positionClass": "toast-top-full-width",
    			  "onclick": null,
    			  "showDuration": "300",
    			  "hideDuration": "1000",
    			  "timeOut": "5000",
    			  "extendedTimeOut": "1000",
    			  "showEasing": "swing",
    			  "hideEasing": "linear",
    			  "showMethod": "fadeIn",
    			  "hideMethod": "fadeOut"
    	}
    	if ('${success }') {
    		toastr.success('${success }');
    	}
    	if ('${error }') {
    		toastr.error('${error }');
    	}
    	
    	function del(obj,positionId){
    	$.get('<%=request.getContextPath()%>/PositionServlet?command=delete&id='+positionId+'&time='+new Date().getTime(),function(text){
    		if (text == 'fail') {
		    	layer.msg('操作失败！', {time: 2000, icon: 5});
		     } else {
		    	layer.msg('操作成功！', {time: 2000, icon: 6});
		    	$(obj.parentNode.parentNode).remove();
		     }
    	});
    	}
    	
    	/**
    	 * 审核
    	 */
    	 function verify(obj,applicationId) {
    	    //询问框
    	    layer.confirm('通过还是拒绝？', {
    	    	closeBtn: 0,
    	        icon : 3,
    	        btn: ['通过','拒绝'] //按钮
    	    }, function(){
    	        layer.msg('您选择了通过！', {icon: 1, time: 1000});
    	        $.get('<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=2&applicationId='+applicationId,function(text){
    	    		if (text == 'fail') {
    			    	layer.msg('操作失败！', {time: 2000, icon: 5});
    			     } else {
    			    	layer.msg('操作成功！', {time: 2000, icon: 6});
    			    	$(obj.parentNode).prev().text("审核通过"+text);
    			    	console.info(obj.parentNode);
    			     }
    	    	});
    	    }, function(){
    	        layer.msg('您选择了拒绝！', {icon: 2, time: 1000});
    	        $.get('<%=request.getContextPath()%>/ApplicationServlet?command=verify&status=3&applicationId='+applicationId,function(text){
    	    		if (text == 'fail') {
    			    	layer.msg('操作失败！', {time: 2000, icon: 5});
    			     } else {
    			    	layer.msg('操作成功！', {time: 2000, icon: 6});
    			    	$(obj.parentNode).prev().text("已拒绝"+text);
    			     }
    	    	});
    	    });
    	}
    		
    	 var searchForm = $('#searchForm')[0];
 		function go(pageNo) {
 			searchForm.action='<%=request.getContextPath() %>/ApplicationServlet?command=listCompanyVerifyByPage&pageNo='+pageNo
 			searchForm.submit();
 		}
 
    	
</script>
    </body>
</html>
